package com.ruoyi.web.controller.market.risk;

import java.util.List;
import java.util.Map;

import com.ruoyi.db.domain.RiskBaseInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.RiskResultInfo;
import com.ruoyi.risk.service.IRiskResultInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.RiskResultInfoWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 风控结果表Controller
 * 
 * @author ruoyi
 * @date 2023-05-26
 */
@Controller
@RequestMapping("/risk/resultInfo")
public class RiskResultInfoController extends BaseController
{
    private String prefix = "risk/resultInfo";

    @Autowired
    private IRiskResultInfoService riskResultInfoService;

    @RequiresPermissions("risk:resultInfo:view")
    @GetMapping()
    public String resultInfo(ModelMap map)
    {

        RiskBaseInfo riskBaseInfo = new RiskBaseInfo();
        List<Map<String,String>> baseInfoList=riskResultInfoService.getdataInfo();
        map.put("riskBaseInfoList",baseInfoList);

        return prefix + "/resultInfo";
    }

    /**
     * 查询风控结果表列表
     */
    @RequiresPermissions("risk:resultInfo:view")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RiskResultInfo riskResultInfo)
    {
        startPage();
        List<Map<String, Object>> mapList = riskResultInfoService.selectRiskResultInfoListMap(riskResultInfo);
        mapList = new RiskResultInfoWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出风控结果表列表
     */
    @RequiresPermissions("risk:resultInfo:export")
    @Log(title = "风控结果表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RiskResultInfo riskResultInfo)
    {
        List<RiskResultInfo> list = riskResultInfoService.selectRiskResultInfoList(riskResultInfo);
        ExcelUtil<RiskResultInfo> util = new ExcelUtil<RiskResultInfo>(RiskResultInfo.class);
        return util.exportExcel(list, "风控结果表数据");
    }

    /**
     * 新增风控结果表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存风控结果表
     */
    @RequiresPermissions("risk:resultInfo:add")
    @Log(title = "风控结果表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RiskResultInfo riskResultInfo)
    {
        return toAjax(riskResultInfoService.insertRiskResultInfo(riskResultInfo));
    }

    /**
     * 修改风控结果表
     */
    @RequiresPermissions("risk:resultInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        RiskResultInfo riskResultInfo = riskResultInfoService.selectRiskResultInfoById(id);
        mmap.put("riskResultInfo", riskResultInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存风控结果表
     */
    @RequiresPermissions("risk:resultInfo:edit")
    @Log(title = "风控结果表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RiskResultInfo riskResultInfo)
    {
        return toAjax(riskResultInfoService.updateRiskResultInfo(riskResultInfo));
    }

    /**
     * 删除风控结果表
     */
    @RequiresPermissions("risk:resultInfo:remove")
    @Log(title = "风控结果表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(riskResultInfoService.deleteRiskResultInfoByIds(ids));
    }
}
